<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.main.PicClient"%>
<%@page import="com.util.XMLExactractor"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Results Page</title>
<link rel="stylesheet" type="text/css"
	href="../picClient/styles/style.css" />
<%
PicClient client=(PicClient)session.getAttribute("object");
String keyword=(String)session.getAttribute("keywrd");
String domain=session.getAttribute( "domain").toString();
String title=session.getAttribute( "title").toString();
String subTitle=session.getAttribute( "subTitle").toString();
String apikey=(String)session.getAttribute("apikey");
String userID=(String)session.getAttribute("uid");
System.out.println(userID);
String servicename=(String)session.getAttribute("service");

//String [] imageURLs= client.getImages(keyword,domain,title,subTitle,userID,apikey,servicename);
String xmlString= client.getImages(keyword,domain,title,subTitle,userID,apikey,servicename);
String[] pImageURLs=new XMLExactractor().getRecommendedPicSEEKImageUrls(xmlString);
String[] picSEEKImages= new String[10];
System.out.println("pImageURLs"+pImageURLs.length);
for(int i=0;i<pImageURLs.length;i++)
{
	picSEEKImages[i]=pImageURLs[i];

}

String[] seImageURLs=new XMLExactractor().getSearchEngineRecommendedImsgeURLs(xmlString);
System.out.println("seImageURLs"+seImageURLs.length);

String[] searchEngineRecommendedImages= new String[10];
for(int i=0;i<10;i++)
{
	searchEngineRecommendedImages[i]=seImageURLs[i];

}

String[] rankings=new XMLExactractor().getImageRankings(xmlString);
String[] imageRankings=new String[20];
for(int i=0;i<pImageURLs.length;i++){
	imageRankings[i]=rankings[i];
	System.out.println("imageRankings "+i+"="+imageRankings[i]);
	
}

for(int i=pImageURLs.length;i<10;i++){
	imageRankings[i]="";
	
}

for(int i=10;i<20;i++){
	imageRankings[i]="GR";
	
}


%>

</head>

<body onLoad="displaynext();">

<script type="text/javascript">
function savetoDB(URL){
	document.location.href="http://localhost:8080/picClient/FeedBack?url="+URL;
}

</script>


<div id="templatemo_container">
<div id="header_Result">
<div id="templatemo_content">
<div id="templatemo_top">
<div class="templatemo_center">
<div id="templatemo_site_title"></div>
<br />
<form method="POST" action="">
<div class="frmText">
<table border="0">
	<tr>
		<td>Search For:</td>
		<td><input type="text" value="" id="searchFor" name="search"
			disabled="true" size="40" /></td>
		<td><input type="submit" value="Search" disabled="true" /></td>
	</tr>
</table>
</div>
<br />

</form>
</div>
</div>
</div>
</div>
<div class="imgSet">
<div align="left" >
<h3>picSEEK Image Recommendation</h3>
</div>
<hr>

<table border="0" cellpadding="3">
<tr>
		<td><img name="im:0" src="<%=picSEEKImages[0] %>" onclick="savetoDB('<%=picSEEKImages[0]%>')" width="150" height="150"/><br><%=imageRankings[0]%></br></td>
		<td><img name="im:1" src="<%=picSEEKImages[1] %>" onclick="savetoDB('<%=picSEEKImages[1]%>')" width="150" height="150"/><br><%=imageRankings[1]%></br></td>
		<td><img name="im:2" src="<%=picSEEKImages[2] %>" onclick="savetoDB('<%=picSEEKImages[2]%>')" width="150" height="150"/><br><%=imageRankings[2]%></br></td>
		<td><img name="im:3" src="<%=picSEEKImages[3] %>" onclick="savetoDB('<%=picSEEKImages[3]%>')" width="150" height="150"/><br><%=imageRankings[3]%></br></td>
		<td><img name="im:4" src="<%=picSEEKImages[4] %>" onclick="savetoDB('<%=picSEEKImages[4]%>')" width="150" height="150"/><br><%=imageRankings[4]%></br></td>
		
</tr>

<tr>
		<td><img name="im:5" src="<%=picSEEKImages[5] %>" onclick="savetoDB('<%=picSEEKImages[5]%>')" width="150" height="150"/><br><%=imageRankings[5]%></br></td>
		<td><img name="im:6" src="<%=picSEEKImages[6] %>" onclick="savetoDB('<%=picSEEKImages[6]%>')" width="150" height="150"/><br><%=imageRankings[6]%></br></td>
		<td><img name="im:7" src="<%=picSEEKImages[7] %>" onclick="savetoDB('<%=picSEEKImages[7]%>')" width="150" height="150"/><br><%=imageRankings[7]%></br></td>
		<td><img name="im:8" src="<%=picSEEKImages[8] %>" onclick="savetoDB('<%=picSEEKImages[8]%>')" width="150" height="150"/><br><%=imageRankings[8]%></br></td>
		<td><img name="im:9" src="<%=picSEEKImages[9] %>" onclick="savetoDB('<%=picSEEKImages[9]%>')" width="150" height="150"/><br><%=imageRankings[9]%></br></td>
</tr>

</table>
<hr>
<h3>Google Image Recommendation</h3>
<hr>

<table border="0" cellpadding="3">
<tr>
		<td><img name="im:10" src="<%=searchEngineRecommendedImages[0] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[0]%>')" width="150" height="150"/><%=imageRankings[10]%></td>
		<td><img name="im:11" src="<%=searchEngineRecommendedImages[1] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[1]%>')" width="150" height="150"/><%=imageRankings[11]%></td>
		<td><img name="im:12" src="<%=searchEngineRecommendedImages[2] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[2]%>')" width="150" height="150"/><%=imageRankings[12]%></td>
		<td><img name="im:13" src="<%=searchEngineRecommendedImages[3] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[3]%>')" width="150" height="150"/><%=imageRankings[13]%></td>
		<td><img name="im:14" src="<%=searchEngineRecommendedImages[4] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[4]%>')" width="150" height="150"/><%=imageRankings[14]%></td>
</tr>

<tr>
		<td><img name="im:15" src="<%=searchEngineRecommendedImages[5] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[5]%>')" width="150" height="150"/><%=imageRankings[15]%></td>
		<td><img name="im:16" src="<%=searchEngineRecommendedImages[6] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[6]%>')" width="150" height="150"/><%=imageRankings[16]%></td>
		<td><img name="im:17" src="<%=searchEngineRecommendedImages[7] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[7]%>')" width="150" height="150"/><%=imageRankings[17]%></td>
		<td><img name="im:18" src="<%=searchEngineRecommendedImages[8] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[8]%>')" width="150" height="150"/><%=imageRankings[18]%></td>
		<td><img name="im:19" src="<%=searchEngineRecommendedImages[9] %>" onclick="savetoDB('<%=searchEngineRecommendedImages[9]%>')" width="150" height="150"/><%=imageRankings[19]%></td>
</tr>
		<td>
			
		<li id="active"><a href="next.jsp" id="current">Next</a></li>

		</td>
<tr>
	
</tr>
</table>
</div>



<div id="templatemo_footer">
<div class="footer_left"></div>
<div class="footer_dot"></div>
<div class="footer_right"></div>
</div>
</div>
</html>
